<?php


namespace app\home\controller;


use app\BaseController;
use think\facade\Db;

class Personal extends BaseController
{
    protected $middleware = [\app\middleware\Check2::class];

    public function index()
    {
        return view();
    }
    public function update(){
        $data = request()->param();
        $user = Db::name('user')->where('id', session('id'))->find();
        if($user['password']!=md5('dytsyq'.$data['old'])){
            return json(['state'=>204,'message'=>'原密码错误']);
        }
        Db::name('user')
            ->save(['id' => session('id'), 'password' => md5('dytsyq'.$data['new'])]);
        return json(['state'=>200,'message'=>'更改成功']);
    }

}